<!DOCTYPE html>
<html lang="zh" dir="ltr" class="client-nojs">
<head>
<title>文本替换宏</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">
<link rel="shortcut icon" href="../../../common/favicon.ico">
<link rel="stylesheet" href="../../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-css:7:15cea3ec788a65b5187d4018eed543bf */</style>

<script src="../../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/preprocessor/replace","wgTitle":"cpp/preprocessor/replace","wgCurRevisionId":63432,"wgArticleId":753,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Todo with reason"],"wgBreakFrames":false,"wgPageContentLanguage":"zh","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"zh","wgMonthNames":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgMonthNamesShort":["","1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"],"wgRelevantPageName":"cpp/preprocessor/replace","wgUserVariant":"zh","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"zh","language":"zh","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-MathJax":1,"gadget-ColiruCompiler":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_zh_:resourceloader:filter:minify-js:7:258d7cd6aa9aa67dee25e01fb6a9e505 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-cpp {line-height: normal;}
.source-cpp li, .source-cpp pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for cpp
 * CSS class: source-cpp, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.cpp.source-cpp  {font-family:monospace;}
.cpp.source-cpp .imp {font-weight: bold; color: red;}
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
.cpp.source-cpp .kw1 {color: #0000dd;}
.cpp.source-cpp .kw2 {color: #0000ff;}
.cpp.source-cpp .kw3 {color: #0000dd;}
.cpp.source-cpp .kw4 {color: #0000ff;}
.cpp.source-cpp .co1 {color: #909090;}
.cpp.source-cpp .co2 {color: #339900;}
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
.cpp.source-cpp .br0 {color: #008000;}
.cpp.source-cpp .sy0 {color: #008000;}
.cpp.source-cpp .sy1 {color: #000080;}
.cpp.source-cpp .sy2 {color: #000040;}
.cpp.source-cpp .sy3 {color: #000040;}
.cpp.source-cpp .sy4 {color: #008080;}
.cpp.source-cpp .st0 {color: #008000;}
.cpp.source-cpp .nu0 {color: #000080;}
.cpp.source-cpp .nu6 {color: #000080;}
.cpp.source-cpp .nu8 {color: #000080;}
.cpp.source-cpp .nu12 {color: #000080;}
.cpp.source-cpp .nu16 {color:#000080;}
.cpp.source-cpp .nu17 {color:#000080;}
.cpp.source-cpp .nu18 {color:#000080;}
.cpp.source-cpp .nu19 {color:#000080;}
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
.cpp.source-cpp span.xtra { display:block; }

/*]]>*/
</style><style type="text/css">/*<![CDATA[*/
.source-text {line-height: normal;}
.source-text li, .source-text pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for text
 * CSS class: source-text, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.text.source-text .de1, .text.source-text .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.text.source-text  {font-family:monospace;}
.text.source-text .imp {font-weight: bold; color: red;}
.text.source-text li, .text.source-text .li1 {font-weight: normal; vertical-align:top;}
.text.source-text .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.text.source-text .li2 {font-weight: bold; vertical-align:top;}
.text.source-text .ln-xtra, .text.source-text li.ln-xtra, .text.source-text div.ln-xtra {background-color: #ffc;}
.text.source-text span.xtra { display:block; }

/*]]>*/
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_preprocessor_replace skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        <!-- /header -->
        <!-- content -->
<div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
<h1 id="firstHeading" class="firstHeading">文本替换宏</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">来自cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../../cpp.html" title="cpp">cpp</a>‎ | <a href="../preprocessor.html" title="cpp/preprocessor">preprocessor</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="zh" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../cpp.html" title="cpp"> C++</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="../language.html" title="cpp/language">语言</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../header.html" title="cpp/header">标准库头文件</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../freestanding.html" title="cpp/freestanding"> 自立与有宿主实现</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../named_req.html" title="cpp/named req">具名要求</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html#.E8.AF.AD.E8.A8.80.E6.94.AF.E6.8C.81" title="cpp/utility">语言支持库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../concepts.html" title="cpp/concepts">概念库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../error.html" title="cpp/error">诊断库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html" title="cpp/utility">工具库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../string.html" title="cpp/string">字符串库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="https://zh.cppreference.com/w/cpp/container" title="cpp/container">容器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../iterator.html" title="cpp/iterator">迭代器库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../ranges.html" title="cpp/ranges"> 范围库</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../algorithm.html" title="cpp/algorithm">算法库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../numeric.html" title="cpp/numeric">数值库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../io.html" title="cpp/io">输入/输出库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../locale.html" title="cpp/locale">本地化库</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../regex.html" title="cpp/regex">正则表达式库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../atomic.html" title="cpp/atomic">原子操作库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../thread.html" title="cpp/thread">线程支持库</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../filesystem.html" title="cpp/filesystem">文件系统库</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../experimental.html" title="cpp/experimental">技术规范</a> </td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../language.html" title="cpp/language">C++ 语言</a><div class="t-navbar-menu"><div><div style="display:inline-block">
<div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> 一般主题</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../preprocessor.html" title="cpp/preprocessor"> 预处理器</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../comments.html" title="cpp/comment"> 注释</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../keywords.html" title="cpp/keyword"> 关键词</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/escape.html" title="cpp/language/escape"> 转义序列</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 流程控制</td></tr>
<tr class="t-nv-h2"><td colspan="5"> 条件执行语句</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/if.html" title="cpp/language/if"> <code>if</code></a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/switch.html" title="cpp/language/switch"> <code>switch</code></a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 重复语句（循环）</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/for.html" title="cpp/language/for"> <code>for</code></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/range-for.html" title="cpp/language/range-for"> 范围 <code>for</code></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/while.html" title="cpp/language/while"> <code>while</code></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/do.html" title="cpp/language/do"> <code>do-while</code></a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 跳转语句 </td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/continue.html" title="cpp/language/continue"> <code>continue</code></a> - <a href="../language/break.html" title="cpp/language/break"> <code>break</code></a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/goto.html" title="cpp/language/goto"> <code>goto</code></a> - <a href="../language/return.html" title="cpp/language/return"> <code>return</code></a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 函数</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/function.html" title="cpp/language/function"> 函数声明</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/lambda.html" title="cpp/language/lambda"> Lambda 函数声明</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/inline.html" title="cpp/language/inline"> <code>inline</code> 说明符</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/except_spec.html" title="cpp/language/except spec"> 异常规定</a> <span class="t-mark-rev t-until-cxx20">(C++20 前)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/noexcept_spec.html" title="cpp/language/noexcept spec"> <code>noexcept</code> 说明符</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 异常</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/throw.html" title="cpp/language/throw"> <code>throw</code> 表达式</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/try_catch.html" title="cpp/language/try catch"> <code>try</code>-<code>catch</code> 块</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 命名空间</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/namespace.html" title="cpp/language/namespace"> 命名空间声明</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/namespace_alias.html" title="cpp/language/namespace alias"> 命名空间别名</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 类型</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/types.html" title="cpp/language/types"> 基础类型</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/enum.html" title="cpp/language/enum"> 枚举类型</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/function.html" title="cpp/language/function"> 函数类型</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/class.html" title="cpp/language/class"> 复合类型</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/union.html" title="cpp/language/union"> 联合体类型</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 说明符</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/decltype.html" title="cpp/language/decltype"> <code>decltype</code></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/auto.html" title="cpp/language/auto"> <code>auto</code></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/alignas.html" title="cpp/language/alignas"> <code>alignas</code></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/cv.html" title="cpp/language/cv"> <code>const</code>/<code>volatile</code></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/constexpr.html" title="cpp/language/constexpr"> <code>constexpr</code></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/storage_duration.html" title="cpp/language/storage duration"> 存储期说明符</a></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 初始化</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/default_initialization.html" title="cpp/language/default initialization"> 默认初始化</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/value_initialization.html" title="cpp/language/value initialization"> 值初始化</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/zero_initialization.html" title="cpp/language/zero initialization"> 零初始化</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/copy_initialization.html" title="cpp/language/copy initialization"> 复制初始化</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/direct_initialization.html" title="cpp/language/direct initialization"> 直接初始化</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/aggregate_initialization.html" title="cpp/language/aggregate initialization"> 聚合初始化</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/list_initialization.html" title="cpp/language/list initialization"> 列表初始化</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/constant_initialization.html" title="cpp/language/constant initialization"> 常量初始化</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/reference_initialization.html" title="cpp/language/reference initialization"> 引用初始化</a></td></tr>
</table></div></td></tr>
</table></div>
</div>
<div style="display:inline-block">
<div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h1"><td colspan="5"> 表达式</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/value_category.html" title="cpp/language/value category"> 值类别</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/eval_order.html" title="cpp/language/eval order"> 求值顺序</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/operators.html" title="cpp/language/operators"> 运算符</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/operator_precedence.html" title="cpp/language/operator precedence"> 运算符优先级</a></td></tr>
</table></div></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/operator_alternative.html" title="cpp/language/operator alternative"> 替代表示</a></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 字面量</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/bool_literal.html" title="cpp/language/bool literal"> 布尔</a> - <a href="../language/integer_literal.html" title="cpp/language/integer literal"> 整数</a> - <a href="../language/floating_literal.html" title="cpp/language/floating literal"> 浮点</a></td></tr>   
<tr class="t-nv"><td colspan="5"> <a href="../language/character_literal.html" title="cpp/language/character literal"> 字符</a> - <a href="../language/string_literal.html" title="cpp/language/string literal"> 字符串</a> - <a href="../language/nullptr.html" title="cpp/language/nullptr"> <code>nullptr</code></a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr> 
<tr class="t-nv"><td colspan="5"> <a href="../language/user_literal.html" title="cpp/language/user literal"> 用户定义</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 工具</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/attributes.html" title="cpp/language/attributes"> 属性</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 类型</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/typedef.html" title="cpp/language/typedef"> <code>typedef</code> 声明</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/type_alias.html" title="cpp/language/type alias"> 类型别名声明</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 类型转换</td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/implicit_cast.html" title="cpp/language/implicit conversion"> 隐式转换</a> - <a href="../language/explicit_cast.html" title="cpp/language/explicit cast"> 显式转换</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/static_cast.html" title="cpp/language/static cast"> <code>static_cast</code></a> - <a href="../language/dynamic_cast.html" title="cpp/language/dynamic cast"> <code>dynamic_cast</code></a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/const_cast.html" title="cpp/language/const cast"> <code>const_cast</code></a> - <a href="../language/reinterpret_cast.html" title="cpp/language/reinterpret cast"> <code>reinterpret_cast</code></a></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 内存分配</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/new.html" title="cpp/language/new"> <code>new</code> 表达式</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/delete.html" title="cpp/language/delete"> <code>delete</code> 表达式</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 类</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/class.html" title="cpp/language/class"> 类声明</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/constructor.html" title="cpp/language/initializer list"> 初始化器列表</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/this.html" title="cpp/language/this"> <code>this</code> 指针</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/access.html" title="cpp/language/access"> 访问说明符</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/friend.html" title="cpp/language/friend"> <code>friend</code> 说明符</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 特定于类的函数性质</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/virtual.html" title="cpp/language/virtual"> 虚函数</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/override.html" title="cpp/language/override"> <code>override</code> 指定符</a>  <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/final.html" title="cpp/language/final"> <code>final</code> 说明符</a>  <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/explicit.html" title="cpp/language/explicit"> <code>explicit</code></a>  <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/static.html" title="cpp/language/static"> <code>static</code></a> </td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> 特殊成员函数</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/default_constructor.html" title="cpp/language/default constructor"> 默认构造函数</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/copy_constructor.html" title="cpp/language/copy constructor"> 复制构造函数</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/move_constructor.html" title="cpp/language/move constructor"> 移动构造函数</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/copy_assignment.html" title="cpp/language/copy assignment"> 复制赋值</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/move_assignment.html" title="cpp/language/move assignment"> 移动赋值</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/destructor.html" title="cpp/language/destructor"> 析构函数</a></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 模板</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/class_template.html" title="cpp/language/class template"> 类模板</a></td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language/function_template.html" title="cpp/language/function template"> 函数模板</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/template_specialization.html" title="cpp/language/template specialization"> 模板特化</a></td></tr>   
<tr class="t-nv"><td colspan="5"> <a href="../language/parameter_pack.html" title="cpp/language/parameter pack"> 参数包</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span></td></tr>
</table></div></td></tr>
<tr class="t-nv-h1"><td colspan="5"> 杂项</td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/asm.html" title="cpp/language/asm"> 内联汇编</a></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <a href="../language/history.html" title="cpp/language/history"> C++ 的历史</a></td></tr>
</table></div></td></tr>
</table></div>
</div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../preprocessor.html" title="cpp/preprocessor">预处理器</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="conditional.html" title="cpp/preprocessor/conditional"><span class="t-lines"><span>#if</span><span>#ifdef</span><span>#ifndef</span><span>#else</span><span>#elif</span><span>#endif</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><strong class="selflink"><span class="t-lines"><span>#define</span><span>#undef</span><span>#,## operators</span></span></strong></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="include.html" title="cpp/preprocessor/include"><span class="t-lines"><span>#include</span><span>__has_include<span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="error.html" title="cpp/preprocessor/error"><span class="t-lines"><span>#error</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="impl.html" title="cpp/preprocessor/impl"><span class="t-lines"><span>#pragma</span><span>_Pragma<span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="line.html" title="cpp/preprocessor/line"><span class="t-lines"><span>#line</span></span></a></div></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div></div>
<p>预处理器支持文本宏替换。亦支持仿函数文本宏替换。
</p>
<h3><span class="mw-headline" id=".E8.AF.AD.E6.B3.95">语法</span></h3>
<table class="t-sdsc-begin">

<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr>
<tr class="t-sdsc">
<td> <code><b>#define</b></code> <span class="t-spar">标识符</span> <span class="t-spar">替换列表</span><span class="t-mark">(可选)</span>
</td>
<td> (1)
</td>
<td class="t-sdsc-nopad">
</td></tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr>
<tr class="t-sdsc">
<td> <code><b>#define</b></code> <span class="t-spar">标识符</span><code><b>(</b></code> <span class="t-spar">形参</span> <code><b>)</b></code> <span class="t-spar">替换列表</span><span class="t-mark">(可选)</span>
</td>
<td> (2)
</td>
<td class="t-sdsc-nopad">
</td></tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr>
<tr class="t-sdsc">
<td> <code><b>#define</b></code> <span class="t-spar">标识符</span><code><b>(</b></code> <span class="t-spar">形参</span><code><b>, ... )</b></code> <span class="t-spar">替换列表</span><span class="t-mark">(可选)</span>
</td>
<td> (3)
</td>
<td> <span class="t-mark-rev t-since-cxx11">(C++11 起)</span>
</td></tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr>
<tr class="t-sdsc">
<td> <code><b>#define</b></code> <span class="t-spar">标识符</span><code><b>( ... )</b></code> <span class="t-spar">替换列表</span><span class="t-mark">(可选)</span>
</td>
<td> (4)
</td>
<td> <span class="t-mark-rev t-since-cxx11">(C++11 起)</span>
</td></tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr>
<tr class="t-sdsc">
<td> <code><b>#undef </b></code> <span class="t-spar">标识符</span>
</td>
<td> (5)
</td>
<td class="t-sdsc-nopad">
</td></tr>



<tr>
<td colspan="10" class="t-sdsc-sep">
</td></tr></table>
<h3><span class="mw-headline" id=".E8.A7.A3.E9.87.8A">解释</span></h3>
<h4><span class="mw-headline" id=".23define_.E6.8C.87.E4.BB.A4"><code>#define</code> 指令</span></h4>
<p><code>#define</code> 指令将 <span class="t-spar">标识符</span> 定义为宏，即指示编译器以将其后出现的所有 <span class="t-spar">标识符</span> 都替换为 <span class="t-spar">替换列表</span>，而它也可以被进一步处理。若该标识符已被定义为任何类型的宏，则除非这些定义都相同，否则程序非良构。
</p>
<h5><span class="mw-headline" id=".E4.BB.BF.E5.AF.B9.E8.B1.A1.E5.AE.8F">仿对象宏</span></h5>
<p>仿对象宏（object-like）以 <span class="t-spar">替换列表</span> 替换每次出现的被定义 <span class="t-spar">标识符</span>。<code>#define</code> 指令的版本 (1) 准确表现如此。
</p>
<h5><span class="mw-headline" id=".E4.BB.BF.E5.87.BD.E6.95.B0.E5.AE.8F">仿函数宏</span></h5>
<p>仿函数宏（function-like）以 <span class="t-spar">替换列表</span> 替换每次出现的被定义 <span class="t-spar">标识符</span>，可选地接受一定量的实参，它们随即替换掉 <span class="t-spar">替换列表</span> 中出现的任何对应的 <span class="t-spar">形参</span>。
</p><p>仿函数宏语法类似函数调用语法：每个宏名实例后随一个 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="br0">(</span></span></span> 作为下个预处理记号，所引入的记号序列将被替换为 <span class="t-spar">替换列表</span>。该序列以匹配的 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="br0">)</span></span></span> 记号终止，跳过中间的匹配左右括号对。
</p><p>对于版本 (2)，实参数量必须与宏定义中的形参数量相同。对于版本 (3,4) ，实参数量必须<span class="t-rev-inl t-until-cxx20"><span>多于</span> <span><span class="t-mark-rev t-until-cxx20">(C++20 前)</span></span></span><span class="t-rev-inl t-since-cxx20"><span>不少于</span> <span><span class="t-mark-rev t-since-cxx20">(C++20 起)</span></span></span>形参数量（不计 <code><b>...</b></code>）。否则程序非良构。若标识符未使用函数写法，即它自身之后无括号，则它完全不被替换。
</p><p><code>#define</code> 指令的版本 (2) 定义简单仿函数宏。
</p><p><code>#define</code> 指令的版本 (3) 定义有可变数量实参的仿函数宏。额外的实参（是谓<i>可变实参</i>）可用 <code>__VA_ARGS__</code> 标识符访问，它会被与要被替换的标识符一起提供的实参替换。
</p><p><code>#define</code> 指令的版本 (4) 定义有可变数量实参的仿函数宏，但无常规实参。额外的实参（是谓<i>可变实参</i>）只能用 <code>__VA_ARGS__</code> 标识符访问，它会被与要被替换的标识符一起提供的实参替换。
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx20"><td>
<p>对于版本 (3,4)，<span class="t-spar">替换列表</span> 可以含有记号序列“<code><b>__VA_OPT__ (</b></code> <span class="t-spar">内容</span> <code><b>)</b></code>”，若 <code>__VA_ARGS__</code> 非空，则它会被 <span class="t-spar">内容</span> 替换，否则不展开成任何内容。
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#define F(...) f(0 __VA_OPT__(,) __VA_ARGS__)</span>
<span class="co2">#define G(X, ...) f(0, X __VA_OPT__(,) __VA_ARGS__)</span>
<span class="co2">#define SDEF(sname, ...) S sname __VA_OPT__(= { __VA_ARGS__ })</span>
F<span class="br0">(</span>a, b, c<span class="br0">)</span> <span class="co1">// 替换为 f(0, a, b, c)</span>
F<span class="br0">(</span><span class="br0">)</span>        <span class="co1">// 替换为 f(0)</span>
G<span class="br0">(</span>a, b, c<span class="br0">)</span> <span class="co1">// 替换为 f(0, a, b, c)</span>
G<span class="br0">(</span>a, <span class="br0">)</span>     <span class="co1">// 替换为 f(0, a)</span>
G<span class="br0">(</span>a<span class="br0">)</span>       <span class="co1">// 替换为 f(0, a)</span>
SDEF<span class="br0">(</span>foo<span class="br0">)</span><span class="sy4">;</span>       <span class="co1">// 替换为 S foo;</span>
SDEF<span class="br0">(</span>bar, <span class="nu0">1</span>, <span class="nu0">2</span><span class="br0">)</span><span class="sy4">;</span> <span class="co1">// 替换为 S bar = { 1, 2 };</span></pre></div></div>
</td>
<td><span class="t-mark-rev t-since-cxx20">(C++20 起)</span></td></tr>
</table>
<p>注意：若仿函数宏的实参中包含不为匹配的左右括号对所保护的逗号（最常出现于模板实参列表中，如 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../error/assert.html"><span class="kw774">assert</span></a><span class="br0">(</span><a href="../types/is_same.html"><span class="kw589">std::<span class="me2">is_same_v</span></span></a><span class="sy1">&lt;</span><span class="kw4">int</span>, <span class="kw4">int</span><span class="sy1">&gt;</span><span class="br0">)</span><span class="sy4">;</span></span></span> 或 <span class="t-c"><span class="mw-geshi cpp source-cpp">BOOST_FOREACH<span class="br0">(</span><a href="../utility/pair.html"><span class="kw1096">std::<span class="me2">pair</span></span></a><span class="sy1">&lt;</span><span class="kw4">int</span>,<span class="kw4">int</span><span class="sy1">&gt;</span> p, m<span class="br0">)</span></span></span>），则逗号被解释成宏实参分隔符，并造成由于实参数量不匹配所致的编译失败。
</p>
<h4><span class="mw-headline" id=".E4.BF.9D.E7.95.99.E5.AE.8F.E5.90.8D"> 保留宏名 </span></h4>
<p>包含标准库头文件的翻译单元不可 <code>#define</code> 或 <code>#undef</code> 声明于任何标准库头文件中所声明的名字。
</p><p>使用标准库任何部分的翻译单元不可 <code>#define</code> 或 <code>#undef</code> 词法上等同于下列内容的名称：
</p>
<ul><li> <a href="../keywords.html" title="cpp/keyword">关键字</a>
</li></ul>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx11"><td>
<ul><li> <a href="../keywords.html" title="cpp/keyword">有特殊含义的标识符</a>
</li><li> <a href="../language/attributes.html#.E6.A0.87.E5.87.86.E5.B1.9E.E6.80.A7" title="cpp/language/attributes">任何标准属性记号</a>
</li></ul>
</td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 起)</span></td></tr>
</table>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx20"><td>
<p>除了可定义 <code>likely</code> 与 <code>unlikely</code> 为仿函数宏。
</p>
</td>
<td><span class="t-mark-rev t-since-cxx20">(C++20 起)</span></td></tr>
</table>
<p>否则，行为未定义。
</p>
<h4><span class="mw-headline" id=".23_.E4.B8.8E_.23.23_.E8.BF.90.E7.AE.97.E7.AC.A6"><code>#</code> 与 <code>##</code> 运算符</span></h4>
<p>仿函数宏中，<span class="t-spar">替换列表</span> 中放在标识符前的 <code>#</code> 运算符，使标识符运行形参替换，并将其结果以引号包围，实际上创建一个字符串字面量。另外，预处理器为内嵌的字符串字面量（若它存在）外围的引号添加反斜杠以进行转义，并按需要双写字符串中的反斜杠。移除所有前导和尾随空白符，并将文本中间（但非内嵌字符串字面量中间）的任何空白符序列缩减成单个空格。此操作被称为“字符串化”，若字符串化的结果不是合法的字符串字面量，则行为未定义。
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx11"><td>
<p><code>#</code> 出现于 <code>__VA_ARGS__</code> 之前时，展开后的 __VA_ARGS__ 整体被包在引号中：
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#define showlist(...) puts(#__VA_ARGS__)</span>
showlist<span class="br0">(</span><span class="br0">)</span><span class="sy4">;</span>            <span class="co1">// 展开成 puts("")</span>
showlist<span class="br0">(</span><span class="nu0">1</span>, <span class="st0">"x"</span>, <span class="kw4">int</span><span class="br0">)</span><span class="sy4">;</span> <span class="co1">// 展开成 puts("1, \"x\", int")</span></pre></div></div>
</td>
<td><span class="t-mark-rev t-since-cxx11">(C++11 起)</span></td></tr>
</table>
<p><span class="t-spar">替换列表</span> 中任何两个相继标识符之间的 <code>##</code> 运算符，使二个标识符（首先未被宏展开）上运行形参替换，然后将结果进行拼接。此操作被称为“拼接”或“记号粘贴”。只有一同组成合法记号的记号才可以粘贴：如组成更长标识符的标识符、组成数字的数字位，或组成 <code>+=</code> 的运算符 <code>+</code> 和 <code>=</code>。不能通过粘贴 <code>/</code> 和 <code>*</code> 来创建注释，因为在考虑文本宏替换前，注释就已被移除了。若连接的结果不是合法记号，则行为未定义。
</p><p>注意：一些编译器提供了一项扩展，允许 ## 出现于逗号后及 __VA_ARGS__ 前，此情况下 ## 在存在可变实参时不做任何事，但在不存在可变实参时移除逗号：这使得可以定义如 <code>fprintf (stderr, format, ##__VA_ARGS__)</code> 这样的宏。
</p>
<h4><span class="mw-headline" id=".23undef_.E6.8C.87.E4.BB.A4"><code>#undef</code> 指令</span></h4>
<p><code>#undef</code> 指令取消定义 <span class="t-spar">标识符</span>，即取消 <code>#define</code> 指令所作的 <span class="t-spar">标识符</span> 定义。若标识符未关联到宏，则忽略该指令。
</p>
<h3><span class="mw-headline" id=".E9.A2.84.E5.AE.9A.E4.B9.89.E5.AE.8F">预定义宏</span></h3>
<p>下列宏名已预定义于每个翻译单元中。
</p>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cplusplus</span></span></div></div>
</td>
<td>  代表所用的 C++ 标准版本，展开成值 199711L<span class="t-mark-rev t-until-cxx11">(C++11 前)</span>、201103L<span class="t-mark-rev t-since-cxx11">(C++11)</span>、201402L<span class="t-mark-rev t-since-cxx14">(C++14)</span> 或 201703L<span class="t-mark-rev t-since-cxx17">(C++17)</span> <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__STDC_HOSTED__</span></span></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  若实现有宿主（运行在 OS 下）则展开成整数常量 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="nu0">1</span></span></span>，若实现自立（不随 OS 运行）则展开成 <span class="t-c"><span class="mw-geshi cpp source-cpp">​<span class="nu0">0</span>​</span></span> <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__FILE__</span></span></div></div>
</td>
<td>  展开成当前文件名，作为字符串字面量，可用 <a href="line.html" title="cpp/preprocessor/line">#line</a> 指令更改 <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__LINE__</span></span></div></div>
</td>
<td>  展开成源文件行号，整数常量，可用 <a href="line.html" title="cpp/preprocessor/line">#line</a> 指令更改 <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__DATE__</span></span></div></div>
</td>
<td>  展开成翻译日期，形式为 "Mmm dd yyyy" 的字符串。若月中日期数小于 10 则 "dd" 的首字符为空格。月份名如同以 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../chrono/c/asctime.html"><span class="kw1015">std::<span class="me2">asctime</span></span></a><span class="br0">(</span><span class="br0">)</span></span></span> 生成 <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__TIME__</span></span></div></div>
</td>
<td>  展开成翻译时间，形式为 "hh:mm:ss" 的字符串字面量 <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__STDCPP_DEFAULT_NEW_ALIGNMENT__</span></span></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx17">(C++17)</span></span></span></div></div>
</td>
<td>  展开成 <span class="t-lc"><a href="../types/size_t.html" title="cpp/types/size t">std::size_t</a></span> 字面量，其值为对不具对齐的 <span class="t-lc"><a href="../memory/new/operator_new.html" title="cpp/memory/new/operator new">operator new</a></span> 的调用所保证的对齐（更大的对齐将传递给具对齐重载，如 <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../memory/new/operator_new.html"><span class="kw687">operator new</span></a><span class="br0">(</span><a href="../types/size_t.html"><span class="kw100">std::<span class="me2">size_t</span></span></a>, <a href="../memory/new/align_val_t.html"><span class="kw697">std::<span class="me2">align_val_t</span></span></a><span class="br0">)</span></span></span>） <br> <span class="t-mark">(宏常量)</span>
</td></tr>
</table>
<p>实现可能预定义下列其他的宏名。
</p>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__STDC__</span></span></div></div>
</td>
<td>  若存在则为实现定义值，典型地用于指示 C 遵从性 <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__STDC_VERSION__</span></span></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  若存在则为实现定义值 <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__STDC_ISO_10646__</span></span></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  若 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">wchar_t</span></span></span> 使用 Unicode ，则展开成 <code>yyyymmL</code> 形式的整数常量，日期指示所支持的 Unicode 的最近版本 <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__STDC_MB_MIGHT_NEQ_WC__</span></span></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  若对于基本字符集成员 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="st0">'x'</span> <span class="sy1">==</span> L<span class="st0">'x'</span></span></span> 可能为假，则展开成 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="nu0">1</span></span></span>，如在基于 EBCDIC 并且为 wchar_t 使用 Unicode 的系统上。 <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__STDCPP_STRICT_POINTER_SAFETY__</span></span></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  若实现支持严格 <span class="t-lc"><a href="../memory/gc/pointer_safety.html" title="cpp/memory/gc/pointer safety">std::pointer_safety</a></span> 则展开成 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="nu0">1</span></span></span> <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__STDCPP_THREADS__</span></span></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx11">(C++11)</span></span></span></div></div>
</td>
<td>  若程序能拥有多于一个执行线程则展开成 <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="nu0">1</span></span></span> <br> <span class="t-mark">(宏常量)</span>
</td></tr>
</table>
<p>这些宏的值（除了 <code>__FILE__</code> 和 <code>__LINE__</code>），在翻译单元间保持为常量。试图重定义或取消定义这些宏导致未定义行为。
</p><p>注意：在每个函数体的作用域内部，都有一个名为 <span class="t-c"><span class="mw-geshi cpp source-cpp">__func__</span></span> 的特殊的函数局域预定义变量<span class="t-mark-rev t-since-cxx11">(C++11 起)</span>，定义为一个持有具有实现定义格式的函数名的静态字符数组。它不是预处理器宏，但它与 <code>__FILE__</code> 和 <code>__LINE__</code> 一起使用，例如 <span class="t-lc"><a href="../error/assert.html" title="cpp/error/assert">assert</a></span>。
</p>
 <table class="t-rev-begin">
<tr class="t-rev t-since-cxx20"><td>
<h4> <span class="mw-headline" id=".E8.AF.AD.E8.A8.80.E5.8A.9F.E8.83.BD.E7.89.B9.E6.80.A7.E6.B5.8B.E8.AF.95.E5.AE.8F">语言功能特性测试宏</span></h4>
<p>下列宏预定义于每个翻译单元。
</p>
<table class="metadata plainlinks ambox mbox-small-left ambox-notice" style=""><tr><td class="mbox-empty-cell"></td><td class="mbox-text" style="">本节未完成<br>原因：在对应功能特性中描述 </td></tr></table>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_aggregate_bases</span></span></div></div>
</td>
<td>   展开成整数字面量 201603L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_aggregate_nsdmi</span></span></div></div>
</td>
<td>   展开成整数字面量 201304L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_aggregate_paren_init</span></span></div></div>
</td>
<td>   展开成整数字面量 201902L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_alias_templates</span></span></div></div>
</td>
<td>   展开成整数字面量 200704L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_aligned_new</span></span></div></div>
</td>
<td>   展开成整数字面量 201606L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_attributes</span></span></div></div>
</td>
<td>   展开成整数字面量 200809L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_binary_literals</span></span></div></div>
</td>
<td>   展开成整数字面量 201304L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_capture_star_this</span></span></div></div>
</td>
<td>   展开成整数字面量 201603L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_char8_t</span></span></div></div>
</td>
<td>   展开成整数字面量 201811L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_concepts</span></span></div></div>
</td>
<td>   展开成整数字面量 201907L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_conditional_explicit</span></span></div></div>
</td>
<td>   展开成整数字面量 201806L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_consteval</span></span></div></div>
</td>
<td>   展开成整数字面量 201811L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_constexpr</span></span></div></div>
</td>
<td>   展开成整数字面量 201907L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_constexpr_dynamic_alloc</span></span></div></div>
</td>
<td>   展开成整数字面量 201907L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_constexpr_in_decltype</span></span></div></div>
</td>
<td>   展开成整数字面量 201711L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_constinit</span></span></div></div>
</td>
<td>   展开成整数字面量 201907L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_coroutines</span></span></div></div>
</td>
<td>   展开成整数字面量 201902L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_decltype</span></span></div></div>
</td>
<td>   展开成整数字面量 200707L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_decltype_auto</span></span></div></div>
</td>
<td>   展开成整数字面量 201304L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_deduction_guides</span></span></div></div>
</td>
<td>   展开成整数字面量 201907L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_delegating_constructors</span></span></div></div>
</td>
<td>   展开成整数字面量 200604L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_designated_initializers</span></span></div></div>
</td>
<td>   展开成整数字面量 201707L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_enumerator_attributes</span></span></div></div>
</td>
<td>   展开成整数字面量 201411L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_fold_expressions</span></span></div></div>
</td>
<td>   展开成整数字面量 201603L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_generic_lambdas</span></span></div></div>
</td>
<td>   展开成整数字面量 201707L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_guaranteed_copy_elision</span></span></div></div>
</td>
<td>   展开成整数字面量 201606L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_hex_float</span></span></div></div>
</td>
<td>   展开成整数字面量 201603L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_if_constexpr</span></span></div></div>
</td>
<td>   展开成整数字面量 201606L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_impl_destroying_delete</span></span></div></div>
</td>
<td>   展开成整数字面量 201806L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_impl_three_way_comparison</span></span></div></div>
</td>
<td>   展开成整数字面量 201907L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_inheriting_constructors</span></span></div></div>
</td>
<td>   展开成整数字面量 201511L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_init_captures</span></span></div></div>
</td>
<td>   展开成整数字面量 201803L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_initializer_lists</span></span></div></div>
</td>
<td>   展开成整数字面量 200806L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_inline_variables</span></span></div></div>
</td>
<td>   展开成整数字面量 201606L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_lambdas</span></span></div></div>
</td>
<td>   展开成整数字面量 200907L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_modules</span></span></div></div>
</td>
<td>   展开成整数字面量 201907L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_namespace_attributes</span></span></div></div>
</td>
<td>   展开成整数字面量 201411L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_noexcept_function_type</span></span></div></div>
</td>
<td>   展开成整数字面量 201510L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_nontype_template_args</span></span></div></div>
</td>
<td>   展开成整数字面量 201911L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_nontype_template_parameter_auto</span></span></div></div>
</td>
<td>   展开成整数字面量 201606L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_nsdmi</span></span></div></div>
</td>
<td>   展开成整数字面量 200809L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_range_based_for</span></span></div></div>
</td>
<td>   展开成整数字面量 201603L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_raw_strings</span></span></div></div>
</td>
<td>   展开成整数字面量 200710L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_ref_qualifiers</span></span></div></div>
</td>
<td>   展开成整数字面量 200710L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_return_type_deduction</span></span></div></div>
</td>
<td>   展开成整数字面量 201304L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_rvalue_references</span></span></div></div>
</td>
<td>   展开成整数字面量 200610L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_sized_deallocation</span></span></div></div>
</td>
<td>   展开成整数字面量 201309L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_static_assert</span></span></div></div>
</td>
<td>   展开成整数字面量 201411L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_structured_bindings</span></span></div></div>
</td>
<td>   展开成整数字面量 201606L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_template_template_args</span></span></div></div>
</td>
<td>   展开成整数字面量 201611L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_threadsafe_static_init</span></span></div></div>
</td>
<td>   展开成整数字面量 200806L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_unicode_characters</span></span></div></div>
</td>
<td>   展开成整数字面量 200704L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_unicode_literals</span></span></div></div>
</td>
<td>   展开成整数字面量 200710L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_user_defined_literals</span></span></div></div>
</td>
<td>   展开成整数字面量 200809L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_using_enum</span></span></div></div>
</td>
<td>   展开成整数字面量 201907L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_variable_templates</span></span></div></div>
</td>
<td>   展开成整数字面量 201304L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_variadic_templates</span></span></div></div>
</td>
<td>   展开成整数字面量 200704L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>__cpp_variadic_using</span></span></div></div>
</td>
<td>   展开成整数字面量 201611L  <br> <span class="t-mark">(宏常量)</span>
</td></tr>
</table>
</td>
<td><span class="t-mark-rev t-since-cxx20">(C++20 起)</span></td></tr>
</table>
<h3><span class="mw-headline" id=".E7.A4.BA.E4.BE.8B">示例</span></h3>
<div class="t-example"><div class="t-example-live-link"><div class="coliru-btn coliru-btn-run-init">运行此代码</div></div>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="cpp source-cpp"><pre class="de1"><span class="co2">#include &lt;iostream&gt;</span>
 
<span class="co1">// 制造函数工厂并使用它</span>
<span class="co2">#define FUNCTION(name, a) int fun_##name() { return a;}</span>
 
FUNCTION<span class="br0">(</span>abcd, <span class="nu0">12</span><span class="br0">)</span>
FUNCTION<span class="br0">(</span>fff, <span class="nu0">2</span><span class="br0">)</span>
FUNCTION<span class="br0">(</span>qqq, <span class="nu0">23</span><span class="br0">)</span>
 
<span class="co2">#undef FUNCTION</span>
<span class="co2">#define FUNCTION 34</span>
<span class="co2">#define OUTPUT(a) std::cout &lt;&lt; "output: " #a &lt;&lt; '\n'</span>
 
<span class="kw4">int</span> main<span class="br0">(</span><span class="br0">)</span>
<span class="br0">{</span>
    <a href="../io/cout.html"><span class="kw1758">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">"abcd: "</span> <span class="sy1">&lt;&lt;</span> fun_abcd<span class="br0">(</span><span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
    <a href="../io/cout.html"><span class="kw1758">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">"fff: "</span> <span class="sy1">&lt;&lt;</span> fun_fff<span class="br0">(</span><span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
    <a href="../io/cout.html"><span class="kw1758">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> <span class="st0">"qqq: "</span> <span class="sy1">&lt;&lt;</span> fun_qqq<span class="br0">(</span><span class="br0">)</span> <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
    <a href="../io/cout.html"><span class="kw1758">std::<span class="me2">cout</span></span></a> <span class="sy1">&lt;&lt;</span> FUNCTION <span class="sy1">&lt;&lt;</span> <span class="st0">'<span class="es1">\n</span>'</span><span class="sy4">;</span>
    OUTPUT<span class="br0">(</span>million<span class="br0">)</span><span class="sy4">;</span>               <span class="co1">// 注意缺少引号</span>
<span class="br0">}</span></pre></div></div>
<p>输出：
</p>
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="text source-text"><pre class="de1">abcd: 12
fff: 2
qqq: 23
34
output: million</pre></div></div> 
</div>
<h3><span class="mw-headline" id=".E5.8F.82.E9.98.85">参阅</span></h3>
<table class="t-dsc-begin">

</table>

<!-- 
NewPP limit report
Preprocessor visited node count: 9425/1000000
Preprocessor generated node count: 16140/1000000
Post‐expand include size: 249514/2097152 bytes
Template argument size: 80820/2097152 bytes
Highest expansion depth: 20/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_zh_:pcache:idhash:753-0!*!0!!zh!*!zh!* and timestamp 20191229042841 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    来自“<a href="https://zh.cppreference.com/mwiki/index.php?title=cpp/preprocessor/replace&amp;oldid=63432">https://zh.cppreference.com/mwiki/index.php?title=cpp/preprocessor/replace&amp;oldid=63432</a>”                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        <div id="cpp-footer-base" class="noprint">
            <div id="footer">
                        <div id="cpp-navigation">
            <h5>导航</h5>
            <ul><li><a href="https://zh.cppreference.com/w/cpp/preprocessor/replace">Online version</a></li><li>Offline version retrieved 2020-03-14 18:00.</li></ul></div>
                        <ul id="footer-info">
                                    <li id="footer-info-lastmod"> 本页面最后修改于2019年12月28日 (星期六) 20:28。</li>
                                    <li id="footer-info-viewcount">此页面已被浏览过16,537次。</li>
                            </ul>
                    </div>
        </div>
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.MathJax","ext.gadget.ColiruCompiler"], null, true);
}</script>
<script src="../../../common/site_scripts.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 0.068 secs. -->
	</body>
<!-- Cached 20191230010306 -->
</html>